<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <!--首先完成移动端的预览设置问题,设备的宽度初始缩放倍数为1.0倍，这里还可以设置用户禁止缩放等等-->
    <meta name="viewport" content="device-width,initial-scale=1.0">
    <title>博客查询</title>
    <!--接下来进行semanticUI的css CDN的引用-->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <!--引入我们自己写的css-->
    <link rel="stylesheet" href="../../static/css/me.css">

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
</head>
<body>

    <!--导航栏-->
    <nav th:replace="admin/_fragments :: menu(1)" class="ui  inverted attached segment m-padded-tb-mini m-shadow-small">

        <!--container的好处很多，其中之一使得设备正常显示-->
        <div class="ui  container">
            <!--使用一个菜单来放我们所有的导航链接-->
            <div class="ui  inverted  secondary stackable menu">

                 <h2 class="ui  teal header item">管理后台</h2>
               &nbsp;
               <a class="active item m-item m-mobile-hide"><i class="fas fa-carrot"></i>博客</a>
               <a class=" item m-item m-mobile-hide"><i class="fas fa-ice-cream"></i>分类</a>
               <a class="item m-item m-mobile-hide" ><i class="fas fa-candy-cane"></i>标签</a>

                <div class="right menu">
                    <div class="ui dropdown item">
                        <div class="text">
                            <img class="ui avatar image" src="https://unsplash.it/100/100?image=1005">
                            曾中杰
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    <!--二级导航-->
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="/admin/fabutype" class=" item">发布</a>
                <a href="#" class="active item">列表</a>
            </div>
        </div>
    </div>

    <!--中部主体-->
    <div class="m-padded-tb-big " >
       <div class="ui stackable container" style="width:  85% !important;">

           <form action="#" method="post"   class="ui secondary segment form">

               <input type="hidden" name="page">


                <div class="inline fields">
                    <div class="field">
                        <input type="text" name="title" placeholder="标题">
                    </div>
                    <div class="field">
                        <div class="ui type selection dropdown">

                            <input type="hidden" name="typeId">

                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div th:each="type : ${types}" th:data-value="${type.id}" th:text="${type.name}" class="item"  data-value="1">错误日志</div>
                              <!-- <div class="item" data-value="2">开发者手册</div>-->
                            </div>
                        </div>
                    </div>

                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="recommend" name="recommend">
                            <label for="recommend" >推荐</label>
                        </div>
                    </div>
                    <div class="field">
                        <button type="button" id="clear-btn" class="ui mini gray basic button"><i class="eraser icon"></i>清除</button>
                    </div>
                    <div class="field">
                        <button type="button" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
                    </div>
                </div>



           </form>

           <div id="table-container">
                <table th:fragment="blogList" class="ui teal  table">
               <thead>
               <tr>
                   <th></th>
                   <th>标题</th>
                   <th>类型</th>
                   <th>推荐</th>
                   <th>状态</th>
                   <th>更新时间</th>
                   <th>操作</th>
               </tr>
               </thead>
               <tbody>
               <tr th:each="blog,iterStat : ${page.content}">
                   <td th:text="${iterStat.count}">1</td>
                   <td th:text="${blog.title}">刻意练习清单</td>
                   <td  th:text="${blog.type.name}">认知升级</td>
                   <td th:text="${blog.recommend} ? '是' : '否'">是</td>
                   <td th:text="${blog.published} ? '发布' : '草稿'"></td>
                   <td th:text="${blog.updateTime}">2017-10-02 09:45</td>
                   <td><a href="#" th:href="@{/admin/blogs/{id}/input(id=${blog.id})}"  class="ui mini teal button">编辑</a>
                       <a href="#" th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" onclick="return confirm('确认删除吗？三思而后行！')" class="ui  mini red button">删除</a></td>
               </tr>
               </tbody>
                <tfoot >
                    <tr>
                        <th colspan="13">
                            <div class="ui pagination menu" th:if="${page.totalPages} > 1">
                                <a onclick="page(this)" th:attr="data-page=${page.number}-1" th:unless="${page.first}"  class="item">上一页</a>
                                <a onclick="page(this)" th:attr="data-page=${page.number}+1" th:unless="${page.last}" class="item">下一页</a>
                            </div>
                            <a href="#" th:href="@{/admin/blogs/input}" class="ui  right floated teal basic button item">新增</a>
                        </th>
                    </tr>
                </tfoot>
           </table>
               <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                   <i class="close icon">
                   </i>
                   <div class="header">提示:</div>
                   <p th:text="${message}"></p>
               </div>
            </div>
       </div>
    </div>
    <br><br><br><br><br> <br><br><br><br><br>

    <!--底部footer栏-->
    <footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment m-padded-tb-massive">

            <!--这里的结构其实跟nav尽量保持一致-->
            <div class="ui center aligned container m-padded-tb-mini">

                <div class="ui stackable inverted divided grid">

                    <div class="three wide column">
                        <div class="ui inverted link list">
                            <div class="item">
                                <img src="../../static/images/qrcode.jpg" class="ui rounded image" style="width: 110px">
                            </div>
                        </div>
                    </div>
                    <div class="three wide column">

                        <h4 class="ui inverted header m-text-spaced m-opacity-small">最新博客</h4>

                        <div class="ui inverted link list ">
                            <a href="#" class="item">用户故事(User Story)</a>
                            <a href="#" class="item">用户故事(User Story)</a>
                            <a href="#" class="item">用户故事(User Story)</a>
                        </div>
                    </div>

                    <div class="three wide column">
                        <h4 class="ui inverted header  m-text-spaced m-opacity-small">联系我</h4>
                        <div class="ui inverted link list m-text-lined">
                            <a href="#" class="item">QQ:1474159935</a>
                            <a href="#" class="item">Wechat:zeng1474159935</a>
                            <a href="#" class="item">Email:1474159935@qq.com</a>
                        </div>
                    </div>

                    <div class="seven wide column">
                        <h4 class="ui inverted header  m-text-spaced m-opacity-small">关于我</h4>
                        <p class="m-text-thin m-text-spaced m-opacity-mini">不知你是否跟我一样，喜欢了解他人如何快乐的生活，积极向他们寻求生活的乐趣。
                           一起勇敢前行吧。</p>
                    </div>
                </div>
                <!--这里是一根线-->
                <div class="ui inverted section divider"> </div>
                <p class="m-text-thin m-text-spaced m-opacity-mini">Copyright©2019-2020zzj Designed by zzj</p>
            </div>


    </footer>

<th:block th:replace="admin/_fragments :: script">
<!--也许用到的jQuery的引用-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<!--这里进行semanticUI的js 的CDN的引用 -->
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
</th:block>

    <script>

        //消息提示关闭初始化
        $('.message .close')
            .on('click', function () {
                $(this)
                    .closest('.message')
                    .transition('fade');
            });

        function page(obj) {
            $("[name='page']").val($(obj).data("page"));
            loaddata();
        }

        $("#search-btn").click(function () {
            loaddata();
        });

        $('#clear-btn')
            .on('click', function() {
                $('.ui.type.dropdown')
                    .dropdown('clear')
                ;
                $("[name='title']").val(null)
            })
        ;

       function firm() {
            alert("你确定要删除吗?三思而后行");
        }



        function loaddata() {
            $("#table-container").load("/admin/blogs/search",{

                title : $("[name='title']").val(),
                typeId : $("[name='typeId']").val(),
                recommend : $("[name='recommend']").prop('checked'),
                page : $("[name='page']").val()

            })
        }

    </script>
</body>
</html>